package com.duyutian.zhanglong.p9类心跳包;

import io.netty.channel.ChannelHandlerAdapter;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.timeout.IdleStateHandler;

import java.util.concurrent.TimeUnit;

/**
 * @Author : duyutian
 * @Date : 2019/11/21 13:25
 * @Version 1.0
 */
public class HeatbeatInitializer extends ChannelInitializer<SocketChannel> {


    @Override
    protected void initChannel(SocketChannel ch) throws Exception {
        ChannelPipeline pipeline = ch.pipeline();
        pipeline.addLast(new IdleStateHandler(5, 7, 4, TimeUnit.SECONDS));
        pipeline.addLast(new HeartBeatHandler());
    }
}
